package com.maple.soa.service.impl;

import com.maple.soa.config.RedisPoolConfig;
import com.maple.soa.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * @author lijian
 * @date 2020/8/6
 */
@Service
public class RedisServiceImpl implements RedisService {
    @Autowired
    private JedisPool jedisPool;

    @Override
    public void set(String key, String val, Integer expires) {
        Jedis jedis = jedisPool.getResource();
        jedis.set(key, val);
        jedis.expire(key, expires);
    }

    @Override
    public String get(String key) {
        Jedis jedis = jedisPool.getResource();
        return jedis.get(key);
    }
}
